package com.meiyou.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.meiyou.pojo.MeiyouEvaluate;
import com.meiyou.pojo.vo.MyPingJia;
import com.meiyou.service.EvaContentService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Controller
@Api(value = "美游app控制器", tags = { "所有api接口" })
public class EvaContentController {
	
	@Resource
	EvaContentService evaContentServiceImpl;

	@RequestMapping(value = "addevaluate", method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "新增评价内容")
	public int AddEvaContent(MeiyouEvaluate meiyouEvaluate) {
		return evaContentServiceImpl.insEvaluate(meiyouEvaluate);
	}

	@RequestMapping(value = "myevaluate", method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "显示我的评价内容")
	public Map<String, Object> MyEvaluate(HttpServletRequest request) {
		String eUCount = request .getSession().getAttribute("user")+"";
		Map<String, Object> map = new HashMap<String, Object>();
		List<MyPingJia> guide = evaContentServiceImpl.selGuidePJ(eUCount);
		List<MyPingJia> yuehui = evaContentServiceImpl.selYuehuiPJ(eUCount);
		List<MyPingJia> tuina = evaContentServiceImpl.selTuinaPJ(eUCount);
		List<MyPingJia> tour = evaContentServiceImpl.selTourPJ(eUCount);
		map.put("guide", guide);
		map.put("yuehui", yuehui);
		map.put("tuina", tuina);
		map.put("tour", tour);
		return map;
	}

	@RequestMapping(value = "delevaluate", method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "删除评价内容")
	public int delEvaluate(int id) {
		return evaContentServiceImpl.delEvaluate(id);
	}
}
